﻿<%@ page contentType="text/html; charset=UTF-8"%>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c" %>
<%@ taglib uri="http://www.ufida.com/multilang" prefix="ml" %>
<%@ taglib uri="http://www.ufida.com/lfw" prefix="lfw" %>
<%@ taglib uri="http://www.ufida.com/uif" prefix="uif" %>
<html>
	<head>
		<lfw:base/>
		<lfw:head/>
		<uif:import/>
		<link rel='STYLESHEET' type='text/css' href='${ROOT_PATH}/${NODE_STYLE_PATH}/desktop.css'>
		<style>
			.noticeContainerBar
			{  
				height:100%;
				border-left-width:1px;
				border-left-style:solid;
				border-left-color:#7F9DB9;
				
				border-top-width:1px;
				border-top-style:solid;
				border-top-color:#7F9DB9;
				
				border-right-width:1px;
				border-right-style:solid;
				border-right-color:#7F9DB9;
				
				padding-left:10px;
				padding-right:10px;
				background-color:#d1e6fb;
			}
			
			#fastKeyBar
			{
				width:100%;
				height:20px;
				background:url('html/themes/ncclassic/images/bar_back_focus.gif') repeat-x 0 -5;
				border-bottom-style:solid;
				border-bottom-width:1px;
				border-bottom-color:#7F9DB9;
			}
			
			.bartitle{
				position:relative;
				color: #000000;
				float:left;
				font-weight: bold;
			    font-family: Arial;
				font-size: 12px;
				background:transparent; 
				padding-top:0px !important;
				padding-top:3px;
			}
			
			.barimage{
				position:relative;
				float:left;
				padding-top:0px !important;
				padding-top:3px;
			}
			
			.wpmenu{
				float:right;
				margin-top:2px;
				margin-right:5px;
			}
			
			.wpmax{
				float:right;
				margin-top:2px;
				margin-right:5px;
			}
			
			.priority_high {
				background: #ffffff url('/lfw/html/image/high.gif') no-repeat center center;
			}
			
			.priority_normal {
				background: #ffffff url('/lfw/html/image/high.gif') no-repeat center center;
			}
			
			.grid_operatecolumn{
				width:50px;
				height:20px;
				position:absolute;
				color:#0042ae;
				font-weight:normal;
				text-decoration: underline;
			}
		</style>
		<uif:webbximport/>
		<script type='text/javascript' src='${ROOT_PATH}/html/nodes/quickdesk/quickdeskutil.js'></script>
	</head>
	<body bottommargin="0" topmargin="0" leftmargin="0" rightmargin="0" scroll=no onload="pageBodyScript()">
		<lfw:pageModel className="nc.lfw.finance.quickdesk.QuickdeskPageModel">
			<div id="bodydiv" style="height:100%;padding:5px;">
				<script>
					if(IS_FF){
						window.onresize = function() {
							adjustBodyDivHeight();
						}
						
						function adjustBodyDivHeight() {
							var bodyDiv = $('bodydiv');
							bodyDiv.style.height = document.body.clientHeight - 10 + "px";
						}
						
						adjustBodyDivHeight();
					}
				</script>
				<lfw:layout type="flowv">
					<lfw:layoutPanel height="49%">
						<div id="mydjdiv" style="width:100%;height:100%;">
							<lfw:layout type="flowv">
								<lfw:layoutPanel height="26px">
									<div class="noticeContainerBar">
										<table width="100%" height="100%">
											<tr>
												<td width="20px"><div class="barimage"><img src="${NODE_IMAGE_PATH}/titleicon.gif"/></div></td>
												<td width="100px"><div class="bartitle">${ml:trans('yer_mybxbill')}</div></td>
												<td><div id="myDjBar" style="width:100%;height:100%;"></div></td>
											</tr>
										</table>
									</div>	
								</lfw:layoutPanel>
								<lfw:layoutPanel>
									<lfw:border width="1">
										<lfw:grid id="myDjGrid"/>
									</lfw:border>
								</lfw:layoutPanel>
							</lfw:layout>
						</div>
					</lfw:layoutPanel>
					<lfw:layoutPanel height="5px">
					</lfw:layoutPanel>
					<lfw:layoutPanel>
						<div id="myjobdiv" style="width:100%;height:100%">
							<lfw:layout type="flowv">
								<lfw:layoutPanel height="26px">
									<div class="noticeContainerBar">
										<table width="100%" height="100%">
											<tr>
												<td width="20px"><div class="barimage"><img src="${NODE_IMAGE_PATH}/titleicon.gif"/></div></td>
												<td width="100px"><div class="bartitle">${ml:trans('yer_myjob')}</div></td>
												<td><div id="myJobBar" style="width:100%;height:100%;"></div></td>
											</tr>
										</table>
									</div>
								</lfw:layoutPanel>
								<lfw:layoutPanel>
									<lfw:border width="1">
										<lfw:grid id="myJobGrid"/>
									</lfw:border>
								</lfw:layoutPanel>		
							</lfw:layout>
						</div>
					</lfw:layoutPanel>
				</lfw:layout>
			</div>
		</lfw:pageModel>
	</body>
</html>
<script>

	function externalInit()
	{
		//WebBxOperateBar(parent, name, left, top, width, height, position,dsId)
		var myDjBar = new WebBxOperateBar(document.getElementById('myDjBar'), "mydjbar" , 0, 0, '100%', '100%', null, getDataset("myDjDs"), {'searchDfValue':"${ml:trans('yer_searchmybxbill')}"});
		var myJobBar = new WebBxOperateBar(document.getElementById('myJobBar'),"myjobbar",0,0,'100%','100%',null,getDataset("myJobDs"),{'searchDfValue':"${ml:trans('yer_searchmyjob')}"});
	}
	
	/**
	 * 我的报销单据
	 */
	function MyDjOperateRender(){}
	MyDjOperateRender.render = function(rowIndex, colIndex, value, header, cell)
	{	
		var ds = getDataset("myDjDs"); 
		var gridRow = header.owner.getRow(rowIndex);
		var row = gridRow.getRowData();
		
		var acomp = $ce("A");  
		acomp.id = "pfinfo_acomp";
		acomp.appendChild(document.createTextNode("${ml:trans('yer_view')}"));
		acomp.className = "grid_operatecolumn"; 
		acomp.style.left = 0;
		acomp.href = "#";
		acomp.onclick = function(e) {
			if(!e)
				e = window.event;
			try{
				openMyBill(ds,row);
			}
			catch(error){}
			stopAll(e);
		};	
		
		var acomp2 = $ce("A");  
		acomp2.id = "pfinfo_acomp2";
		acomp2.appendChild(document.createTextNode("${ml:trans('yer_print')}"));
		acomp2.className = "grid_operatecolumn";  
		acomp2.style.left = 35;
		acomp2.href = "#";
		acomp2.onclick = function(e) {
			if(!e)
				e = window.event;
			try{
				//获取nc节点
				var funnode = row.getCellValue(ds.nameToIndex("webnodecode"));
				var pk_jkbx = row.getCellValue(ds.nameToIndex("pk_jkbx"));
				var djdl = row.getCellValue(ds.nameToIndex("djdl"));
				var param = "funnode=" + funnode + "&pk_jkbx=" + pk_jkbx + "&djdl=" + djdl;
				var args = new Array;
				args.push("pk_jkbx=" + pk_jkbx + "&djdl=" + djdl);
				//增加判断，新的"E0100205"这个功能采取导出数据的方式。
				if(funnode = 'E0100205'){
					//window.location.href = "/yer/exceldownload?pk="+pk_jkbx+"&key=E0100205&classpath=nc.ebs.exportexcel.ExcelPlan";
					window.location.href = "/yer/txtfiledownload?pk="+pk_jkbx+"&key=E0100205";
				}else{
					var cmd = new CommonCommand('doPrint');
					cmd.setAsync(true);
					cmd.setParameter(param);
					cmd.setReturnFunc(printReturnFun);
					cmd.setReturnArgs(args);
					cmd.exec();
				}
				
				
			}
			catch(error){}
			stopAll(e);
		};
		
		
		var acomp3 = $ce("A");  
		acomp3.id = "pfinfo_acomp3";
		acomp3.appendChild(document.createTextNode("${ml:trans('yer_pf')}"));
		acomp3.className = "grid_operatecolumn";  
		acomp3.style.left = 70;
		acomp3.href = "#";
		acomp3.onclick = function(e) {
			if(!e)
				e = window.event;
			try{
				var billId = row.getCellValue(ds.nameToIndex("pk_jkbx"))
				var billType = row.getCellValue(ds.nameToIndex("djlxbm"));
				var url = getCorePath() + "/pfinfo/pfinfo.jsp?pageId=pfinfo&billId="+ billId +"&billType=" + encodeURIComponent(billType) + "&rand=" + (Math.random()*10000).toString().substring(0, 4);
				
				var width = screen.width;
				var height = screen.height;
				var dlgWidth = 600,dlgHeight = 450;
				if(dlgWidth > document.body.clientWidth){
					dlgWidth = document.body.clientWidth - 40;
				}			
								
				showDialog(url , "${ml:trans('yer_pfinfo')}", dlgWidth, dlgHeight, "pfinfoDialog", true,true);
			}
			catch(error){}
			stopAll(e);
		};
		
		//附件
		var fujianComp = getFujianComp(ds,row,105);
		
		cell.style.overflow = "hidden";
		cell.style.textOverflow = "ellipsis";
		cell.style.cursor = "default";
		cell.style.textAlign = "center";
		cell.appendChild(acomp);
		cell.appendChild(acomp2);
		cell.appendChild(acomp3);
		cell.appendChild(fujianComp);
	}
	function getFujianComp(ds,row,left){
		var comp = $ce("A");  
		comp.id = "pfinfo_fujian";
		comp.appendChild(document.createTextNode("${ml:trans('yer_fujian')}"));
		comp.className = "grid_operatecolumn";  
		comp.style.left = left;
		comp.href = "#";
		comp.onclick = function(e) {
			if(!e)
				e = window.event;
			try{
				var pk_jkbx = row.getCellValue(ds.nameToIndex("pk_jkbx"))
				var url = getCorePath() + "/docmanage/docmanage.jsp?pageId=docmanage" 
						+ "&delegator=" + "nc.lfw.finance.file.FileManageDelegator"
						+ "&pk_jkbx=" + pk_jkbx
						+ "&rand=" + (Math.random()*10000).toString().substring(0, 4);
				showDialog(url , "${ml:trans('yer_filemanage_title')}", "550", "350", "attachmentDialog", true,true);
				
			}
			catch(error){}
			stopAll(e);
		};
		return comp;
	}
	
	function printReturnFun(result, args, success)
	{
		if(success) 
		{ 
			var filePath = result[0];
			if(filePath != null && filePath != "" && filePath != "NEEDSELECT")
				window.open(getRootPath() + "/printfile.pdf?filePath=" + filePath, "xxx", "toolbar=no,menubar=yes,scrollbar=yes,resizable=yes,location=no,status=no,fullscreen=no");
			else if(filePath == "NEEDSELECT")
				this.showPrintDlg(result, args[0]);
		}
		hideProgressDialog();
	}
	
	function showPrintDlg(selectResult, param)
	{
		if(window["$print_Template_ids_select_dlg"] == null)
		{
			var dlg = new ModalDialogComp("print_Template_ids_select_dlg", "${ml:trans('yer_chooseprinttemplate')}", 0, 0, 300, 200);
			var labelComp = new LabelComp(dlg, "print_Template_ids_select_dlg_label", 40, 32, "${ml:trans('yer_choosetemplate')}", "absolute");
			var idsComboComp = new ComboComp(dlg, "print_Template_ids_select_dlg_printIdsCombo", 100, 30, 150, "absolute");
			var okBtn = new ButtonComp(dlg, "print_Template_ids_select_dlg_OkBtn", 70, 120, 70, 20, "${ml:trans('BxContrastPageModel-000000')}", "${ml:trans('BxContrastPageModel-000000')}", null, "absolute");
			var cancelBtn = new ButtonComp(dlg, "print_Template_ids_select_dlg_CancelBtn", 160, 120, 70, 20, "${ml:trans('BxContrastPageModel-000001')}", "${ml:trans('BxContrastPageModel-000001')}", null, "absolute");
			this.showPrintDlg.comboComp = idsComboComp;
			window["$print_Template_ids_select_dlg"] = dlg;
			
			var oThis = this;
			okBtn.onclick = function(e)
			{
				var selectedValue = idsComboComp.getValue();
				if(selectedValue == null)
				{
					showMessageDialog("${ml:trans('yer_chooseusedprinttemplate')}");
					return;	
				}
				
	//			var args = new Array;
	//			args.push(paramStr);
				// 再次向后台发送ajax请求,此时传递用户选择的模版id
				
				var cmd = new CommonCommand('doPrint');
				cmd.setAsync(true);
				cmd.setParameter(param + "&selectedTemplateId=" + selectedValue);
				cmd.setReturnFunc(oThis.printReturnFun);
				cmd.setCallObj(this);
				cmd.exec();
				
				//processCommonLogic(param + "&selectedTemplateId=" + selectedValue, "doPrint", oThis.printReturnFun, null, true, null, null, this);
				showProgressDialog("${ml:trans('yer_wait')}");
				dlg.hide();
			};
			
			cancelBtn.onclick = function(e)
			{
				dlg.hide();
			};
		}
		
		window["$print_Template_ids_select_dlg"].show();
		var combo = this.showPrintDlg.comboComp;
		combo.clearOptions();
		var keyValues = null;
		for(var i = 1, count = selectResult.length; i < count; i++)
		{
			keyValues = selectResult[i];
			keyValues = keyValues.split(";");
			if(i == 1)
				combo.createOption(keyValues[1], keyValues[0], null, true);	
			else
				combo.createOption(keyValues[1], keyValues[0]);
		}
	};

	/**
	 * 我的代办事务
	 */
	function MyJobOperateRender(){}
	MyJobOperateRender.render = function(rowIndex, colIndex, value, header, cell)
	{	
		var ds = getDataset("myJobDs"); 
		var gridRow = header.owner.getRow(rowIndex);
		var row = gridRow.getRowData();
				
		var acomp = $ce("A");  
		acomp.id = "pfinfo_job_acomp";
		acomp.appendChild(document.createTextNode("${ml:trans('yer_view')}")); 
		acomp.className = "grid_operatecolumn";
		acomp.style.left = 0;
		acomp.href = "#";
		acomp.onclick = function(e) {
			if(!e)
				e = window.event;
			try{
				openMyBill(ds,row);
			}
			catch(error){}
			stopAll(e);
		};	
		//附件
		var fujianComp = getFujianComp(ds,row,33);
		
		cell.style.overflow = "hidden";
		cell.style.textOverflow = "ellipsis";
		cell.style.cursor = "default";
		cell.style.textAlign = "center";
		cell.appendChild(acomp);
		cell.appendChild(fujianComp);
	}

	/**
	 * 审批状态
	 */
	function MySpztRender(){}
	MySpztRender.render = function(rowIndex, colIndex, value, header, cell)
	{	
		var ds = getDataset('myDjDs');
		var caption = "";
		if(value == -1 || value == null)
			caption = "${ml:trans('WebBxMainPageQueryPageModel-000010')}";
		else if(value == -10000)
			caption = "${ml:trans('WebBxMainPageQueryPageModel-000009')}";
		else { 
			var pfStateArray = ["${ml:trans('WebBxMainPageQueryPageModel-000005')}","${ml:trans('WebBxMainPageQueryPageModel-000006')}",
								"${ml:trans('WebBxMainPageQueryPageModel-000007')}","${ml:trans('WebBxMainPageQueryPageModel-000008')}"]; 
			caption = pfStateArray[value]
		}
		cell.style.overflow = "hidden";
		cell.style.textOverflow = "ellipsis";
		cell.style.cursor = "default";
		cell.style.textAlign = "center";
		cell.innerHTML  = "<center>" + caption + "<center>" ;
	}
	
	//支付状态
	function MyDjPayFlagRender(){}
	MyDjPayFlagRender.render = function(rowIndex, colIndex, value, header, cell)
	{	
		cell.style.overflow = "hidden";
		cell.style.textOverflow = "ellipsis";
		cell.style.cursor = "default";
		cell.style.textAlign = "center";
		var caption = "";
		if(value == 20)
			caption ="${ml:trans('WebBxMainPagePayFlag05')}";
		else if(value == 99)
			caption = "${ml:trans('WebBxMainPagePayFlag06')}";
		else{
			var arr = ["","${ml:trans('WebBxMainPagePayFlag01')}","${ml:trans('WebBxMainPagePayFlag02')}","${ml:trans('WebBxMainPagePayFlag03')}","${ml:trans('WebBxMainPagePayFlag04')}"];
			caption = arr[value];
		}
		cell.innerHTML  = "<center>" + caption + "<center>" ;
	}
	
	/**
	 * 打开我的单据
	 */
	function openMyBill(ds,dsRow)
	{  
 		if(dsRow != null)
 		{
 			var billId = dsRow.getCellValue(ds.nameToIndex("pk_jkbx"));
   			var billNo = dsRow.getCellValue(ds.nameToIndex("djbh"));
   			var isHavePower = dsRow.getCellValue(ds.nameToIndex("isHavePower"));
   			var isLfwWeb = dsRow.getCellValue(ds.nameToIndex("isLfwWeb"));
   			var funCode = dsRow.getCellValue(ds.nameToIndex("funCode"));
   			var linkURL = dsRow.getCellValue(ds.nameToIndex("linkUrl"));   
   			var funName = dsRow.getCellValue(ds.nameToIndex("funName"));
  			if(isHavePower == 'N')	{
   				showWarningDialog("${ml:trans('yer_quickdeskmodel016')}");
   				return;
   			}
   			// 参考FunRegisterConst.java
   			if(funCode != null){
   				var tab = parent.getComponent("pageTab");
   				// 如果有打开的相同funCode的页签则先关闭
   				var itemIndex = tab.getItemIndexByName(funCode);
   				if(itemIndex != -1)
   					tab.removeItemTab(itemIndex);
   				
   				
 				var param = "&approveid=" + billId + "&pkmessage=" + dsRow.getCellValue(100);
 				//begin ncm wangshb
//   				if(ds.id == 'myDjDs'){
// 	   				param += "&approve_type=0" ;//+ dsRow.getCellValue(ds.nameToIndex('msgType'))
//   				}else if(ds.id == 'myJobDs')
//   					param += "&approve_type=1" ;
   				param+= "&approve_type=1" ;
   				//end ncm wangshb
    			parent.openNode(funCode, linkURL + param, {title:funName, approveid:billNo});
   			}
   		}
	}

	function JkbxJeRender(){};
	JkbxJeRender.render = function(rowIndex, colIndex, value, header, cell)
	{
		cell.style.overflow = "hidden";
		cell.style.textOverflow = "ellipsis";
		cell.style.cursor = "default";
		cell.style.textAlign = "right";
		
		var grid = header.owner;
		var ds = grid.model.dataset;
		var gridRow = grid.getRow(rowIndex);
		var row = gridRow.getRowData();
		
		var pre = parseInt(row.getCellValue(ds.nameToIndex('precision')));
		if(value == null || value == ''){
			value = "0.";
			for(var i=0; i<pre; i++)
				value += "0";
		}else{
			value = value + "";
			if(value.indexOf(".") == -1){
				value += ".";
				for(var i=0; i<pre; i++)
					value += "0";
			}else if(parseFloat(value) == 0){//值为0
				value = "0.";
				for(var i=0; i<pre; i++)
					value += "0";
			}else{//正常浮点数
				value = getDoubleByTrimZero(value);
				if(value.indexOf(".") == -1){
					value += "." ;
					for(var i=0; i<pre; i++)
						value += "0";
				}else{
					var arr = value.split(".");
					var c = pre - parseInt(arr[1].length);
					if(c > 0){
						for(var i=0; i<c; i++)
							value += "0";				
					}
				}
			}
		}
		value=formatNum(value,pre)
		cell.innerHTML  = value;
	};
	/*去掉0*/
	function getDoubleByTrimZero(value){
		var index = -1;
		var count = value.length-1;
		for(var i=count;i>=0;i--){
			var ch = value.charAt(i);
			if(ch == '.'){
				index = i;
				break;	
			}else if(ch != '0'){
				index = i+1;
				break;	
			}
		}
		return (index == -1) ? value : value.substring(0,index) ;
	}
	/**
	 * 无需调用后台destroy方法
	 */
	function onBeforeDestroyPage()
	{
		return false;
	}
</script>	